package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.DigitalCollectionProductInfoAuctionUserBidding;
import com.sc.nft.entity.DigitalCollectionProductInfoAuctionUserBiddingResults;
import com.sc.nft.entity.UserPredictEcologyHatchRewardsRecords;
import com.sc.nft.entity.vo.AuctionConsumeAdminPageVO;
import com.sc.nft.entity.vo.AuctionDataDetailsVO;
import com.sc.nft.entity.vo.AuctionUserBiddingAdminPageVO;
import com.sc.nft.entity.vo.UserAuctionWinVO;
import com.sc.nft.mapper.DigitalCollectionProductInfoAuctionUserBiddingMapper;
import com.sc.nft.mapper.DigitalCollectionProductInfoAuctionUserBiddingResultsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.dao
 * @Project：sc_metago
 * @name：DigitalCollectionProductInfoAuctionDao
 * @Date：2024/9/5 14:57
 * @Filename：DigitalCollectionProductInfoAuctionDao
 */
@Slf4j
@Repository
public class DigitalCollectionProductInfoAuctionUserBiddingResultsDao extends ServiceImpl<DigitalCollectionProductInfoAuctionUserBiddingResultsMapper, DigitalCollectionProductInfoAuctionUserBiddingResults> {


    public DigitalCollectionProductInfoAuctionUserBiddingResults getByProductIdAndUserId(Long userId, Long productId) {
        LambdaQueryWrapper<DigitalCollectionProductInfoAuctionUserBiddingResults> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DigitalCollectionProductInfoAuctionUserBiddingResults::getProductId,productId);
        wrapper.eq(DigitalCollectionProductInfoAuctionUserBiddingResults::getUserId,userId);
        wrapper.last("order by id desc limit 1");
        return getOne(wrapper);
    }

    public IPage<UserAuctionWinVO> auctionWinList(Long productId, Page mp) {
        return baseMapper.auctionWinList(mp,productId);
    }

    /**
     * 批量插入拍卖结果
     *
     * @param digitalCollectionProductInfoAuctionUserBiddingResultsList
     */
    public void saveList(List<DigitalCollectionProductInfoAuctionUserBiddingResults> digitalCollectionProductInfoAuctionUserBiddingResultsList) {
        baseMapper.saveList(digitalCollectionProductInfoAuctionUserBiddingResultsList);
    }

    /**
     * 拍卖数据汇总
     * @param productId
     * @return
     */
    public AuctionDataDetailsVO auctionDataDetails(Long productId) {
        return baseMapper.auctionDataDetails(productId);
    }


    /**
     * 投标用户列表
     * @param productId
     * @param userTel
     * @param progress
     * @param page
     * @return
     */
    public Page<AuctionUserBiddingAdminPageVO> getAuctionUserBiddingAdminPage(Long productId, String userTel, Integer progress, Page page) {
        return baseMapper.auctionUserBiddingAdminPage(productId,userTel,progress,page);
    }


}
